<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>计算器</h1>
<p>
    整数1：<input type="text" title="" id="one">
</p>
<p>
    整数2：<input type="text" title="" id="two">
</p>
<p>
    <button onclick="count('jia')">加</button>
    <button onclick="count('jian')">减</button>
    <button onclick="count('cheng')">乘</button>
    <button onclick="count('chu')">除</button>
</p>
<p>
    新数据：<input type="text" title="" id="new">
</p>

<script>
    function count(q){
        var a = document.querySelector("#one").value;
        var b = document.querySelector("#two").value;
        var sum = 0;
        switch (q){
            case 'jia':
                a = Number(a);
                b = Number(b);
                sum = a + b;
                document.querySelector("#new").value = sum;
                break;
            case 'jian':
                sum = a - b;
                document.querySelector("#new").value = sum;
                break;
            case 'cheng':
                sum = a * b;
                document.querySelector("#new").value = sum;
                break;
            case 'chu':
                sum = a / b;
                document.querySelector("#new").value = sum;
                break;
        }
    }
</script>

</body>
</html>